
 begintownscript;

 variables;

 int i,j,k,r1,choice;

 body;

 beginstate INIT_STATE;

	set_name(6,"Kharl");
	set_name(7,"Tybonson");
	set_name(8,"Mahrmmrrh");
	set_name(9,"Uppo");
	set_name(10,"Mayor Worrington");
	set_name(11,"Captain Remington");
	set_char_dialogue_pic(11,1957,0);
	set_name(12,"Ilina");
	set_name(13,"Pieter");
	set_name(14,"Asp");
	set_name(15,"Solid");
	set_name(16,"Traveling Merchant");
	set_name(38,"Leamon");

	set_level(14,25);

	set_crime_tolerance(1);

	if (get_flag(205,4) == 0 && species_in_party(3) == 0) {
		force_instant_terrain_redraw();
		message_dialog("You enter the mining town of Sattle, or at least you were told it's a mining town. One look at the town tells you something isn't right. The guards are restless and the few villagers you notice are obviously frightened.","");
		set_flag(205,4,1);
}

	if (get_flag(205,4) == 0 && species_in_party(3) > 0 && (species_in_party(0) != 0 && species_in_party(2) != 0)) {
		force_instant_terrain_redraw();
		message_dialog("You enter the mining town of Sattle, or at least you were told it's a mining town. One look at the town tells you something isn't right. The guards are eyeing you suspiciously. The few villagers you notice, walk away from you.","It's because of the slith in your party. The guards are looking at the slith with hate-filled eyes. It can't be just simple prejudice.");
		set_flag(205,4,1);
}

	if (get_flag(2,4) == 2)
		activate_hidden_group(3);

	if (get_flag(2,13) >= 2) 
		set_flag(50,3,0);


	if (species_in_party(0) == 0 && species_in_party(2) == 0 && get_flag(2,14) == 0) {
force_instant_terrain_redraw();
		set_state_continue(13);
}


break;

 beginstate START_STATE;

	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(6,"The end is coming!");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(6,"Destruction awaits!");
	if ((get_ran(1,0,100) < 6) && (get_flag(2,13) < 2))
		text_bubble_on_char(7,"Welcome!");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(10,"We should wait.");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(10,"Villagers are restless.");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(11,"They are strong.");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(11,"What if we...");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(18,"Baa!");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(19,"Baaa!");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(20,"Baa!");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(21,"Baaa!");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(18,"Baa-aa!");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(19,"Ba-aaa!");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(20,"Baaa-a!");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(21,"Ba-aa!");
	if (get_ran(1,0,100) < 2)
		text_bubble_on_char(21,"Moo!");

	if ((get_flag(2,12) == 1) || (get_flag(17,17) >= 2) && (get_flag(17,9) == 1)) {
		erase_char(14);
		erase_char(15);
}


	if (get_flag(2,13) < 2) 
		set_flag(50,3,1);


	if (get_flag(2,13) == 2) {
		relocate_character(7,38,19);
		set_character_facing(7,4);
		set_creature_memory_cell(7,0,1);
}

break;

 beginstate EXIT_STATE;

break;

 beginstate 10;
	if (get_flag(2,0) == 0) {
		message_dialog("You try the door. It's locked. In fact, it's more than locked, it's bolted tight from the inside. There is no way, you can open this door.","Suddenly you hear a low muffled voice coming from the room. _What's the password?_");
		get_text_response("What say you?");
		check_text_response_match("regicide");

		if (got_text_match()) {
			set_flag(2,0,1);
			message_dialog("You here footsteps behind the door. Then you hear someone moving the bolts away from the door. You can go in now.","");
}
		else {
			message_dialog("You get no response. Obviously you didn't know the right password.","");
			block_entry(1);
}
}
 break;

 beginstate 11;
	if (get_flag(2,9) == 0 && species_in_party(3) > 0) {
		message_dialog("You enter a small crowded inn. Basically, it's patrons are soldiers. After you take few steps into the inn, the commotion inside fades away. The soldiers are all looking at you with amazed expressions.","One of the soldiers close to you jumps up and is about to attack you. Lucky for you his companions restrain him. One of the soldiers speaks to you. _Sorry friend, we just didn't expect a lizard walking in._");
		set_flag(2,9,1);
}
 break;

 beginstate 12;
	if (get_flag(2,10) == 0) {
		message_dialog("This small building has served as a booking house. The shelves are full of figures about the amount of iron mined and sent forward for processing. Right now the room is dusty. It hasn't been used for weeks.","");
		set_flag(2,10,1);
}
 break;

 beginstate 13;
	force_view_center(39,24);
	activate_hidden_group(12);
	relocate_character(11,39,24);
force_instant_terrain_redraw();
	relocate_character(0,40,24);
	relocate_character(1,41,24);
	relocate_character(2,42,24);
	relocate_character(3,43,24);
	relocate_character(4,44,24);
	relocate_character(5,45,24);
	add_char_to_group(40,1);
	add_char_to_group(41,1);
	add_char_to_group(42,1);
	add_char_to_group(43,1);
	add_char_to_group(44,1);
	add_char_to_group(45,1);
	add_char_to_group(46,1);
	pause(5);
	text_bubble_on_char(11,"Hold your fire men!");
force_instant_terrain_redraw();
	pause(5);
	text_bubble_on_char(11,"");
force_instant_terrain_redraw();
	pause(6);

	reset_dialog();
	add_dialog_str(0,"The captain in front of you throws a quick grin at you. _Well, I didn't believe Sam when he said the lizards are coming but here you are_",0);
	if (get_flag(205,5) == 2)
		add_dialog_str(1,"_Now I've been told you have a piece of paper from the mayor of Grimson. May I please see it?_ You show the captain your deputation papers. He reads them over and nods approvingly. _I could tell you weren't from the mines._",0);
	if (get_flag(205,5) == 1)
		add_dialog_str(2,"_Now I can see that you are not sliths from the mines, but you did kill that patrol. Although I'm afraid I already know why you did so, but care to explain?_"0);
	if (get_flag(205,5) == 0)
		add_dialog_str(3,"_Now judging from your appearance, you are not from the iron mines. Care to explain why you are here? Just so my men are at ease._",0);
	if (get_flag(205,5) == 2)
		add_dialog_str(4,"The captain orders the soldiers to disperse. _I'll make sure everyone in Sattle knows you are on our side. Don't expect a warm welcome, though. Come see me at my office when you're done exploring the town._ The captain departs also.",0);
	if (get_flag(205,5) == 2)
		add_dialog_choice(0,"OK.");
	if (get_flag(205,5) == 1)
		add_dialog_choice(0,"The soldiers attacked us!");
	if (get_flag(205,5) == 0)
		add_dialog_choice(0,"We work for the Empire.");
	choice = run_dialog(1);

	if (choice == 1)
		set_state_continue(14);
 break;

 beginstate 14;
	if (get_flag(205,5) == 1)
		message_dialog("The captain shakes his head. _I was afraid of that. Those poor bastards. I'm guessing you work for the Empire, right? Thought so, you don't look like the sliths that have been attacking us. Come to my office and we'll discuss some more._","The captain orders the soldiers to disperse. _I'll make sure everyone in Sattle knows you are on our side. Don't expect a warm welcome, though._ The captain departs also.");
	if (get_flag(205,5) == 0)
		message_dialog("Thought so, you don't look like the sliths that have been attacking us. Come to my office and we'll discuss some more about the attacks._","The captain orders the soldiers to disperse. _I'll make sure everyone in Sattle knows you are on our side. Don't expect a warm welcome, though._ The captain departs also.");

	relocate_character(11,13,9);
	erase_char(1001);
	set_flag(2,14,1);
 break;
